home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Special 23
/
AMIGAplus Sonderheft 23 (2000)(Falke)(DE)[!].iso
/
PublicDomain
/
Anwendungen
/
FWTabTools
/
Calc
/
FWCalcTab.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1998-01-08
|
17KB
|
8 lines
/* $VER: 0.32 beta, (02.01.1998), © by Thorsten Willert
Macro um einer FinalWriter-Tabellen
die GRUNDfunktionen einer
Tabellenkalkulation beizubringen.
-----------------------------------------------*/
;ADDRESS='FinaW';OPTIONS CACHE RESULTS;STATUS PORTNAME;FW=RESULT;ADDRESS=FW;SIGNAL ON BREAK_C;SIGNAL ON HALT;SIGNAL ON SYNTAX;PRAGMA("W","NULL");IF ~show('L',"rexxreqtools.library") THEN;DO;IF ~addlib('rexxreqtools.library',0,-30,0) THEN;DO;'ShowMessage 1 1 "Error ..." "Missing rexxreqtools.library!" "" "Exit" "" ""';EXIT 20;END;END;ADDRESS Command "RESIDENT c:copy";ADDRESS Command "RESIDENT c:delete";ADDRESS Command "RESIDENT c:join";ADDRESS Command "RESIDENT c:sort";Prefs.TASK=PRAGMA("ID");RT.Version="0.32 (beta)";RT.Title="FWCalcTab";RT.Para1="rt_pubscrname = FinalWriterPubScreen rt_topoffset = 50 rt_reqpos = reqpos_topleftwin";RT.Copyright="© 1997-98, by Thorsten Willert";Prefs.Prefs=RT.Title||".prefs";Prefs.Catalog=RT.Title||".catalog";Prefs.Guide=RT.Title||".guide";Text.5="_Exit";Text.8=" User break! ";Text.9="Syntax Error!";Message.100="Can not open FWCalcTab.catalog!";CALL Locale(Prefs.Catalog);IF LoadPrefs(Prefs.Prefs)=0 THEN;DO;IF SetPrefs(Prefs.Prefs)=1 THEN CALL LoadPrefs(Prefs.Prefs);END;Datei.TMP=Prefs.TMPDir||Prefs.TASK;Datei.TMP1= Datei.TMP||".TMP1";Datei.TMP2= Datei.TMP||".TMP2";Datei.TMP3= Datei.TMP||".TMP3";Datei.TMP4= Datei.TMP||".TMP4";Datei.TMP5= Datei.TMP||".TMP5";Datei.TMP6= Datei.TMP||".TMP6";CALL Info;Datei.Formel= DocInfos();IF EXISTS( Datei.Formel) THEN ADDRESS command 'COPY' Datei.Formel 'TO' Datei.TMP1;ELSE CALL Message(4,);DO FOREVER;Commando=rtezrequest(Text.1,Text.2,RT.Title,RT.Para1);IF Commando==0 THEN CALL Ende;IF Commando=3 THEN;DO;CALL Help;ITERATE;END;IF TableDimension()=1 THEN;DO;Table.Name=GetTabName();CALL SelectFormeln(Table.Name);SELECT;WHEN Commando=1 THEN;DO;Table.OPZellen=GetOps();CALL ReCalc;Redraw;IF EXISTS( Datei.TMP6) THEN;DO;ADDRESS command 'join' Datei.TMP6 Datei.TMP3 'TO' Datei.TMP1;IF RC=20 THEN ADDRESS command 'copy' Datei.TMP6 'TO' Datei.TMP1;ADDRESS command 'sort' Datei.TMP1 Datei.TMP1;END;END;WHEN Commando=2 THEN CALL FormelEditor;OTHERWISE NOP;END;END;END;Ende:;IF Coordinaten=1 THEN Coordinaten=RemoveCoordinaten();CALL Clear;ADDRESS command 'copy' Datei.TMP1 Datei.Formel;EXIT;LoadPrefs:PROCEDURE EXPOSE Prefs. Message. Text. RT.;PARSE ARG Prefs.Prefs;IF EXISTS("ENVARC:"||Prefs.Prefs) THEN;DO;IF OPEN(File,"ENV:"||Prefs.Prefs,"R") THEN;DO WHILE ~EOF(File);INTERPRET("Prefs."||READLN(File));END;CALL CeckPrefs;CLOSE(File);END;ELSE RETURN 0;RETURN 1;SetPrefs:PROCEDURE EXPOSE Prefs. Message. Text. RT.;PARSE ARG Prefs.Prefs;IF OPEN(File,"ENVARC:"||Prefs.Prefs,"W") THEN;DO;CALL WritePrefs;CLOSE(File);ADDRESS COMMAND "COPY ENVARC:"||Prefs.Prefs "TO ENV:"||Prefs.Prefs;RETURN 1;END;RETURN 0;WritePrefs:PROCEDURE EXPOSE Prefs. Message. Text. RT.;WRITELN(File,'/*' Prefs.Prefs 'Version 0.1,' RT.Copyright '*/ 0A'X);WRITELN(File,'ResBold = 1');WRITLEN(File,'ResNegMark = 1');WRITELN(File,'Viewer = "SYS:Utilities/MultiView"');WRITELN(File,'HelpGuide = "HELP:'||Prefs.Sprache||'/'||Prefs.Guide||'"');WRITELN(File,'TMPDir = "T:"');RETURN;CeckPrefs:PROCEDURE EXPOSE Prefs. Message. Text. RT.;IF Prefs.ResBold ~=0&Prefs.ResBold ~=1 THEN Prefs.ResBold=1;IF Prefs.ResNegMark ~=0&Prefs.ResNegMark ~=1 THEN Prefs.ResNegMark=1;IF ~EXISTS(Prefs.Viewer) THEN CALL Message(7,Prefs.Viewer);IF ~EXISTS(Prefs.HelpGuide) THEN CALL Message(6,Prefs.HelpGuide);IF ~EXISTS(Prefs.TMPDir) THEN Prefs.TMPDir="T:";RETURN;Locale:PROCEDURE EXPOSE Message. Text. RT. R Prefs.;CatalogOK=0;IF EXISTS("ENV:Language") THEN;IF OPEN( Datei,"ENV:Language","R") THEN Prefs.Sprache=READLN( Datei);ELSE;Sprache=english;CLOSE( Datei);IF EXISTS("Locale:Catalogs/"||Prefs.Sprache||"/"||Prefs.Catalog) THEN CatalogOK=ReadCatalog(Prefs.Sprache);ELSE IF EXISTS("Locale:Catalogs/english/"||Prefs.Catalog) THEN CatalogOK=ReadCatalog("english");IF CatalogOK=0 THEN;DO;CALL Message(100,Prefs.Catalog);CALL Ende;END;RETURN;ReadCatalog:PROCEDURE EXPOSE Message. Text. RT. R Prefs.;PARSE ARG Sprache;R='0A'X;OffenDatei=0;IF OPEN(Locale,"Locale:Catalogs/"||Sprache||"/"||Prefs.Catalog,"R") THEN;DO WHILE ~EOF(Locale);InZeile=READLN(Locale);INTERPRET(InZeile);OffenDatei=1;END;CLOSE(Locale);Prefs.Form=Color.Form;Prefs.Res=Color.Res;Prefs.Neg=Color.Neg;RETURN OffenDatei;DocInfos:PROCEDURE EXPOSE FW Message. RT. Text. Prefs.;ADDRESS (FW);STATUS PathName;Path=RESULT;IF Path="" THEN;DO FOREVER;CALL Message(5,);SaveAs;IF RC=0 THEN LEAVE;ELSE CALL BREAK_C;END;FormelDatei=Path||".CALC";RETURN FormelDatei;GetTabName:PROCEDURE EXPOSE RT. Message. Text. FW Prefs.;DO FOREVER;GetObjectTitle;TabellenName=RESULT;IF TableDimension()=1 THEN;DO;IF TabellenName ~="RESULT"&LENGTH(COMPRESS(TabellenName))>2 THEN;DO;TabellenName=STRIP(TRANSLATE(TabellenName,"_"," "));LEAVE;END;ELSE;DO;CALL Message(2,);TablePrefs Prompt;IF RC ~=0 THEN CALL BREAK_C;END;END;ELSE CALL Message(1,);END;RETURN TabellenName;SelectFormeln:PROCEDURE EXPOSE Datei. Message. Text. RT. Prefs.;PARSE ARG Tabelle;IF EXISTS( Datei.TMP1) THEN;DO;OPEN( Datei1, Datei.TMP1,"R");OPEN( Datei2, Datei.TMP2,"W");OPEN( Datei3, Datei.TMP3,"W");DO WHILE ~EOF( Datei1);InZeile=READLN( Datei1);Tab=SUBWORD(InZeile,1,1);IF InZeile="" THEN ITERATE;IF Tab=Tabelle THEN WRITELN( Datei2,InZeile);ELSE WRITELN( Datei3,InZeile);END;CLOSE( Datei1);CLOSE( Datei2);CLOSE( Datei3);END;RETURN;TableDimension:PROCEDURE EXPOSE Table. FW Message. RT. Text. Prefs.;TableOK=1;ADDRESS(FW);TableGetColumns;PARSE VAR RESULT Muell Table.Spalten;TableGetRows;PARSE VAR RESULT Muell Table.Zeilen;IF Table.Zeilen=""|Table.Spalten="" THEN;DO;CALL Message(1,);TableOK=0;END;RETURN TableOK;InsertCoordinaten:PROCEDURE EXPOSE Table. FW Prefs.;ADDRESS(FW);TableInsertRows 1 1;Redraw;TableInsertColumns 1 1 1;Redraw;i=0;j=0;DO WHILE i ~=Table.Zeilen;i=i+1;TableSetActiveCell i+1 1;Justify Center;Type i;END;DO WHILE j ~=Table.Spalten|j=27;j=j+1;TableSetActiveCell 1 j+1;ABC= D2C(64+j);Justify Center;Type ABC;END;Coordinaten=1;RETURN Coordinaten;RemoveCoordinaten:PROCEDURE;TableDeleteColumns 1 1 Force;TableDeleteRows 1 1 Force;RETURN 0;GetOps:PROCEDURE EXPOSE Datei. Message. Text. RT. Prefs.;OPZellen="";OPEN(File1, Datei.TMP2,"R");OPEN(File2, Datei.TMP4,"W");DO WHILE ~EOF(File1);Formel=SUBWORD(READLN(File1),5);Ops=TRANSLATE(Formel," ","=+-/()*%;:");DO I=1 TO WORDS(Ops);WRITELN(File2,SUBWORD(Ops,I,1));END;END;CLOSE(File1);CLOSE(File2);ADDRESS command "SORT" Datei.TMP4 Datei.TMP4;OPEN(File1, Datei.TMP4,"R");DO WHILE ~EOF(File1);Out=READLN(File1);IF Out=OldOut| DATATYPE(Out,"NUMERIC")=1 THEN ITERATE;OPZellen=OPZellen Out;OldOut=Out;END;CLOSE(File1);RETURN STRIP(OPZellen);Formeleditor:;Coordinaten=InsertCoordinaten();IF ViewFormel( Datei.TMP2)=0 THEN CALL Message(3,Table.Name);DO FOREVER;res=rtezrequest(Text.3,Text.4,RT.Title,RT.Para1);IF TableDimension()=1&GetTabName()=Table.Name THEN;DO;IF res==1 THEN;DO;CALL SaveForms;LEAVE;END;ELSE IF res==2 THEN CALL Help;ELSE LEAVE;END;ELSE CALL Message(8,Table.Name);END;IF Coordinaten=1 THEN Coordinaten=RemoveCoordinaten();IF EXISTS( Datei.TMP2) THEN;DO;ADDRESS command 'join' Datei.TMP2 Datei.TMP3 'TO' Datei.Formel;IF RC=20 THEN ADDRESS command 'copy' Datei.TMP2 'TO' Datei.Formel;ADDRESS command 'COPY ' Datei.Formel 'TO' Datei.TMP1;Table.OPZellen=GetOps();CALL ReCalc;END;ReDraw;RETURN;ViewFormel:PROCEDURE EXPOSE Prefs. RT. Message. Text.;PARSE ARG Datei;OK=0;IF EXISTS( Datei) THEN;DO;OK=OPEN(File, Datei,"R");DO WHILE ~EOF(File);InZeile=READLN(File);PARSE VAR InZeile TabellenNameD Formel Zeile Spalte Dummy;IF InZeile="" THEN ITERATE;RESULT=ExtractFormel(Formel);PARSE VAR RESULT Function","Dummy;TableSetActiveCell Zeile+1 Spalte+1;SelectAll;Clear;Justify Left;FontColor Prefs.Form;Style Normal;Type "="||Function;OK=1;END;CLOSE(File);END;ReDraw;RETURN OK;ReadOps:;PARSE ARG ReadZellen;I=0;DO I=1 TO WORDS(ReadZellen);OP=SUBWORD(ReadZellen,I,1);RESULT=ParseZelle(OP,1);PARSE VAR RESULT Zeile "," Spalte "," Zelle;IF Zelle ~="OK" THEN ITERATE;Inhalt=CheckZahl(Zeile Spalte);INTERPRET(OP "=" Inhalt);END;RETURN;ZellenDem:PROCEDURE EXPOSE Table. Message. Text. RT. Prefs.;PARSE ARG Zeile,Spalte;Zelle="OK";IF Spalte<=0|Spalte>Table.Spa